<!DOCTYPE html>
<html lang="zh-hans">
<head>
    <meta charset="UTF-8">
    <title>Dicom Demo</title>
</head>
<body>

<div id="dicom">
    <input type="file" id="dicom-file"/>
    <hr>
    <img id="dicom-img">
</div>

<script src="{{ url_for('static', filename='jquery-3.7.0.js') }}"></script>
<script>
    $('#dicom-file').on('change', function (evt) {
        // 构造表单
        const formData = new FormData();
        formData.set('dicom', $('#dicom-file').prop('files')[0]);
        // 进行上传
        $.ajax({
            type: 'POST',
            data: formData,
            processData: false,
            contentType: false,
            success: function (resp) {
                console.log(resp)
                // 上传成功回调
                // TODO: 这块可以校验下，resp code是否为200？ 即后端是否处理成功
                $('#dicom-img').attr('src', resp['data']['dicom'])
            }
        });
    });
</script>
</body>
</html>